package com.lottery.material.entity.admin;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.lottery.material.entity.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * Description：用户表
 * Created by 朱正磊 on 2019-03-22 0:53
 */
@Entity
@Data
@EqualsAndHashCode(callSuper = false)
@Table(name = "tb_user")
public class User extends BaseEntity {

    private static final long serialVersionUID = 7598553338020110832L;

    @Column(columnDefinition = "varchar(255) comment '账户名'")
    private String userName;

    @Column(columnDefinition = "varchar(255) comment '昵称'")
    private String nickName;

    @Column(columnDefinition = "varchar(255) comment '用户密码'")
    private String password;

    @Column(columnDefinition = "int(11) comment '性别：0-女；1-男'")
    private Integer sex;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @Column(columnDefinition = "datetime comment '出生日期'")
    private Date birthday;

    @Column(columnDefinition = "varchar(255) comment '电话'")
    private String telephone;

    @Column(columnDefinition = "varchar(255) comment '邮箱'")
    private String email;

    @Column(columnDefinition = "varchar(255) comment '住址'")
    private String address;

    @Column(columnDefinition = "int(11) comment '逻辑删除状态：0-未删除；1-删除'")
    private Integer deleteStatus;

    @Column(columnDefinition = "int(11) comment '是否锁定：0-未锁定；1-锁定'")
    private Integer locked;

    @Column(columnDefinition = "varchar(255) comment '用户描述'")
    private String description;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @Column(columnDefinition = "datetime comment '更新时间'")
    private Date updateTime;

    @ManyToMany(cascade = { CascadeType.REFRESH }, fetch = FetchType.LAZY)
    @JoinTable(name = "tb_user_role", joinColumns = { @JoinColumn(name = "user_id") }, inverseJoinColumns = { @JoinColumn(name = "role_id") })
    private Set<Role> roles;

}
